import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86183
 * Date: 2023-03-27
 * Time: 15:51
 */
public class test06 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = 0;
        while ((n = scanner.nextInt()) != 0){
            System.out.println(Bottle(n));
        }
    }

    private static int Bottle(int n) {
        int sum = 0;
        while (n > 1){
            sum += n / 3;
            n = n / 3 + n % 3;
            if(n == 2){
                sum++;
                break;
            }
        }
        return sum;
    }
}
